<section class="vbox">
	<section class="scrollable  wrapper">
		<div class="m-b-md">
			<h3 class="m-b-none">编辑角色</h3>
		</div>
		<section class="panel panel-default">
			<div class="panel-body" id="coupons_set">
				<form class="form-horizontal form-validate" method="post" action="<?php echo \Yii::$app->urlManager->createUrl('role/update'); ?>">
					<div class="form-group">
						<label class="col-sm-2 control-label must">角色名：</label>
						<div class="col-sm-4">
							<input class="form-control" name="role_name" data-rule-required="true" data-rule-maxlength="10" value="<?php echo $info['name'];?>"></div>
						<div class="col-sm-2">
							<p class="form-control-static text-muted">10字以内</p>
						</div>

					</div>
					<div class="line line-dashed line-lg pull-in"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">角色描述：</label>
						<div class="col-sm-3">
							<textarea rows="4" class="form-control" name="description" style="margin: 0px -277px 0px 0px; width: 605px; height: 214px;"><?php echo $info['description'];?></textarea>
						</div>

					</div>
					<div class="line line-dashed line-lg pull-in"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label must">有效状态：</label>
						<div class="col-sm-8">
							<label class="radio-inline"><input type="radio" name="status" data-rule-required="true" value="1" <?php if($info['status'] == 1):?>checked<?php endif;?>/>正常使用</label>
							<label class="radio-inline"><input type="radio" name="status" data-rule-required="true" value="0" <?php if($info['status'] == 0):?>checked<?php endif;?>/>禁止使用</label>
						</div>
					</div>
					<div class="line line-dashed line-lg pull-in"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">添加权限：</label>
						<div class="col-sm-10">
							<?php foreach($data as $menus):?>
								<div class="js_first_right m-b-sm clearfix"><!--一级目录div-->
									<div class="bg-light padder" style="padding-bottom:5px">
										<label class="checkbox m-n i-checks">
											<input type="checkbox" class="js_first_checkbox" value="<?php echo $menus['id'];?>" <?php if(in_array($menus['id'], $selectNav)):?>checked="checked"<?php endif;?> /><i></i>
											<?php echo $menus['name'];?>
										</label>
									</div>
									<?php foreach($menus['childMenu'] as $childMenus):?>
										<div class="col-sm-12 js_second_right m-t-xs m-l-md"><!--二级目录div-->
											<label class="checkbox m-n i-checks">
												<input type="checkbox" class="js_second_checkbox" value="<?php echo $childMenus['id'];?>"  <?php if(in_array($childMenus['id'], $selectNode)):?>checked="checked"<?php endif;?> /><i></i>
												<?php echo $childMenus['name'];?>
											</label>

											<?php if(false == empty($childMenus['childMenu'])):?>
												<div class="col-sm-12 js_third_right m-t-xs  m-l-md"><!--三级目录div-->
													<?php foreach($childMenus['childMenu'] as $childMenu):?>
														<label class="checkbox-inline i-checks">
															<input type="checkbox" class="js_third_checkbox" name="access_node[]" value="<?php echo $childMenus['nav_id'];?>:<?php echo $childMenus['id'];?>:<?php echo $childMenu['id'];?>" <?php if(in_array($childMenu['id'], $selectNode)):?>checked="checked"<?php endif;?> /><i></i>
															<?php echo $childMenu['name'];?>
														</label>
													<?php endforeach;?>
												</div>
											<?php endif;?>
										</div>
									<?php endforeach;?>
								</div>
							<?php endforeach;?>
						</div>
					</div>

					<div class="line line-dashed line-lg pull-in"></div>

					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-2">
							<input type="hidden" name="role_id" value="<?php echo $info['id'];?>"/>
							<button type="submit" class="btn btn-primary">保存</button>
							<button type="button" class="btn btn-default" data-toggle="back">取消</button>
						</div>
					</div>
				</form>
			</div>
		</section>
	</section>
</section>
<script type="text/javascript">
	$(document).on("click", ".js_first_checkbox", function() {
		var a = $(this),
				d = a.closest(".js_first_right"),
				e = a.prop("checked");
		b(e, $("input[type='checkbox']", d))
	});
	$(document).on("click", ".js_second_checkbox", function() {
		var a = $(this),
				d = a.closest(".js_second_right"),
				e = a.prop("checked"),
				f = a.closest(".js_first_right"),
				g = $(".js_first_checkbox", f),
				h = $(".js_second_checkbox:checked", f).length;
		b(h, g), b(e, $("input[type='checkbox']", d))
	});
	$(document).on("click", ".js_third_checkbox", function() {
		var a = $(this),
				d = a.closest(".js_third_right"),
				e = a.prop("checked"),
				f = a.closest(".js_first_right"),
				g = a.closest(".js_second_right"),
				h = $(".js_second_checkbox", g),
				i = $(".js_first_checkbox", f),
				j = $(".js_third_checkbox:checked", d).length;
		$(".js_four_checkbox", g).length && (b(e, $("input[type='checkbox']", d)), j = $(".js_third_checkbox:checked", g).length), b(j, h);
		var k = $(".js_second_checkbox:checked", f).length;
		b(k, i)
	});
	$(document).on("click", ".js_four_checkbox", function() {
		var a = $(this),
				d = a.closest(".js_four_right"),
				e = (a.prop("checked"), a.closest(".js_first_right")),
				f = a.closest(".js_second_right"),
				g = a.closest(".js_third_right"),
				h = $(".js_third_checkbox", g),
				i = $(".js_second_checkbox", f),
				j = $(".js_first_checkbox", e),
				k = $(".js_four_checkbox:checked", d).length;
		b(k, h);
		var l = $(".js_third_checkbox:checked", f).length;
		b(l, i);
		var m = $(".js_second_checkbox:checked", e).length;
		b(m, j)
	})
	function b(a, b) {
		a ? b.prop("checked", !0) : b.prop("checked", !1)
	}
</script>

